Skip to content

Feature: carrow_asap & related functions#4

Open
thecapn32 wants to merge 1 commit into
pylover:masterfrom
thecapn32:master
Open

Feature: carrow_asap & related functions#4
thecapn32 wants to merge 1 commit into
pylover:masterfrom
thecapn32:master

Conversation

@thecapn32

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread carrow.c
}
struct asapbag *bag = _asapbags[_asapbagscount];

if (bag == NULL) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always happening situation. if no needed.

Comment thread carrow.c
};


struct asapbag {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use struct evbag instead. We need to schedule coroutines to run as soon as possible.

Comment thread carrow.c


static void
asap_trigger() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ues carrow_trigger instead.

Comment thread carrow.h
typedef void (*carrow_generic_corofunc) (void *coro, void *state);


/* A function pointer type representing a carrow asap function */

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not define it.

Comment thread carrow.h


int
carrow_asap_register(carrow_asapfunc func, void *params);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signature must be similar to carrow_evloop_register.

Comment thread carrow_generic.c
int
CARROW_NAME(forever) (CARROW_NAME(corofunc) f, CARROW_ENTITY *state,
volatile int *status) {
volatile int *status, unsigned int asapsmax) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asapmax is garbage here.

@pylover pylover left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Define a macro similar with CORO_WAIT for asap running.
  • Check _asapbagscount on mainloop conditions(terminate and before wait).

Comment thread carrow.c
return -1;
}

_asapsmax = asapsmax;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get or set it by two accessors:

int
carrow_asapmax_get();

void
carrow_asapmax_set(int count);

Comment thread carrow.c
@@ -314,6 +396,10 @@ carrow_evloop(volatile int *status) {

evloop:
while (_evbagscount && ((status == NULL) || (*status > EXIT_FAILURE))) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check _asapbags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants